#ifndef CRYPTO_UTIL_H
#define CRYPTO_UTIL_H

#include <string>
#include <utility>

const constexpr char* CryptoUtil_h_secretKey = "1234";

namespace l
{

    class CryptoUtil {
    public:

        static bool hashWithSalt(std::string& hashPassword, std::string& salt, const std::string& passWord, size_t saltSize = 8);

        static bool hashFileContent(std::string& hashResult, const std::string& fileContent);

        // 验证带盐值的哈希
        static bool verifyHashWithSalt(const std::string& passWord, const std::string& storedHash, const std::string& salt);

        //利用密钥和有效时间(秒)生成token
        static std::string generate_jwt_token(const char* secret_key = CryptoUtil_h_secretKey, int validTime = 3600);

        //验证token，利用token和密钥
        static bool verify_jwt(const char* token, const char* secret_key = CryptoUtil_h_secretKey);

    };

}//end of namespace l

#endif